package cn.sx.service;

import cn.sx.dao.TypesDao;
import cn.sx.entity.Goods;
import cn.sx.entity.Type;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/*
 *@program:sx_emall_ssm
 *@author: sx
 *@desc: 类型服务
 *@Time: 2020/9/20  12:32
 */
@Service
public class TypesService {
    @Autowired
    private TypesDao typesDao;

    /*查询全部*/
    public List<Type> findAll(){
        return typesDao.selectList();
    }

    /*通过用户名获取（验证）*/
    public Type selectByTypeName(String name) {
        return typesDao.selectByTypeName(name);
    }


    /*根据id查询 */
    public Type get (int id){
        return typesDao.select(id);
    }
    /*获取总数*/
    public int getCount(){
        return typesDao.selectCount();
    }
    public List<Goods> getListByType(int id, int page, int size) {
        return null;
    }



    //后台
    /*后台 删除用户根据id*/
    public int deleteType(int id){
        return typesDao.delete(id);
    }

    /*后台添加类目管理*/
    public boolean typeAdd(Type types){
        return typesDao.insert(types);
    }

    /*后台修改类目信息*/
    public boolean update (int id,String name,int num){
        Type type = new Type();
        type.setId(id);
        type.setName(name);
        type.setNum(num);
        return typesDao.update(type);
    }

}
